// jsmud: JavaScript MUD Kernel
// Copyright (C) 2005,2008 Mojodo, Inc.
// All rights reserved.
// See COPYING for licensing details.

// ---- Database ----

DB.queryRow = function(sql)
{
	var result = DB.query.apply(null, arguments);
	return result.next();
}

DB.queryAll = function(sql)
{
	var result = DB.query.apply(null, arguments);
	var array = new Array();
	var object;
	while (object = result.next())
		array[array.length] = object;
	return array;
}

// ---- File ----

File.getLines = function(path)
{
	file = File.get(path);
	return file.split(/\n/);
}

// ---- ZMP ----

Net.registerZMP('zmp.time', function(){});
Net.registerZMP('zmp.support', function(){});
Net.registerZMP('zmp.no-support', function(){});

Net.registerZMP('zmp.ping', function(client, argv){
	client.sendZMP(['zmp.time', 'FIXME']);
});

Net.registerZMP('zmp.check', function(client, argv){
	if (argv.length == 1) {
		if (hasZMP(argv[1]))
			client.sendZMP(['zmp.support', argv[1]]);
		else
			client.sendZMP(['zmp.no-support', argv[1]]);
	}
});

Net.registerZMP('zmp.input', function(client, argv){
	if (argv.length == 2) {
		client.onInput(argv[1]);
	}
});
